<template>
	<div class="home">
		<cmd-nav-bar iconOne="menu" back left-text="发布挂失"></cmd-nav-bar>
		<div class="not_thing"></div>
		<div class="title_choose">
		</div>
		<div class="choose_dog" v-for="n in dogList" v-bind='n' @click="to_org(n)" :class="{border_org: n.flag }">
			<div class="head">
				<img :src="n.head" alt="" style="border-radius: 50%;">
			</div>
			<div class="name">{{n.name}}</div>
			<div class="gender">
				<div class="img_box">
					<img src="../../myimg/boy.png" v-if="n.gender == 1" alt="">
					<img src="../../myimg/girl.png" v-if="n.gender == 2" alt=""></div>
				<div class="age">{{n.age}}</div>
			</div>
		</div>
		<div class="list_text to_top">
			<mt-field label="犬只品种" placeholder="请输入犬只品种" v-model="dogType"></mt-field>
		</div>
		<div class="list_text">
			<mt-field label="丢失时间" placeholder="请输入丢失时间" type="date" v-model="lossTime"></mt-field>
		</div>
		<div class="list_text">
			<mt-field label="联系电话" placeholder="请输入联系电话" v-model="phone"></mt-field>
		</div>
		<!-- <div class="list_text">
			<mt-field label="酬金" placeholder="请输入酬金" v-model="money"></mt-field>
		</div> -->
		<!-- <div class="text_area"></div>
		<view class="uni-textarea">
			<textarea @blur="bindTextAreaBlur" @focus="noContent" auto-height v-model="contentLoss" />
			</view>
		</view>
				<div class="img_box">
					<img src="../../myimg/uolode.png" alt="">
				</div> -->
		<div class="next_tip" @click='toNext'>
			发布
		</div>
	</div>
	</div>
</template>
<script>
	import head1 from '@/pages/myimg/dog1.jpg'
	import head2 from '@/pages/myimg/dog2.jpg'

	import cmdNavBar from "@/components/cmd-nav-bar/cmd-nav-bar.vue"
	export default {
		props: {},
		components: {
			cmdNavBar
		},
		data() {

			return {

				dogType: '泰迪',
				lossTime: '',
				phone: '',
				money: '',
				contentLoss: '请输入想说的话...',
				title: 'input',
				focus: false,
				inputValue: '',
				changeValue: '',
				keys: 0,
				dogList: [{
						"name": '鱼仔弟弟',
						"age": '2018-10-23',
						"head": head1,
						"gender": 1,
						"flag": false,
					}, {
						"name": '胖头妹',
						"age": '2018-11-20',
						"head": head2,
						"gender": 2,
						"flag": false,
					},
					{
						"name": '胖头妹2',
						"age": '2018-11-20',
						"head": head2,
						"gender": 2,
						"flag": false,
					}
				]
			}
		},
		methods: {
			bindTextAreaBlur: function(e) {
				if (this.contentLoss == "") {
					this.contentLoss = '请输入内容...'
				}
			},
			noContent: function() {
				this.contentLoss = '';
				console.log(this.contentLoss)
			},
			toNext() {
				// uni.navigateTo({
				// 	url: 'lossDetails'
				// });
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},


			bindDateChange: function(e) {
				console.log(e)
				// this.date = e.target.value
			},


			to_org(n) {
				this.dogList.map(function(item) {
					if (item.name != n.name) {
						item.flag = false
					} else {
						n.flag = true
					}
					return item
				})
			},



		},
		watch: {


		},

		onReachBottom() { //页面上拉触底事件的处理函数

		},
		onPullDownRefresh() { //监听用户下拉动作，一般用于下拉刷新
			//需要在 pages.json 里，找到的当前页面的pages节点，并在 style 选项中开启 enablePullDownRefresh
			//uni.startPullDownRefresh(); 开启
			// uni.stopPullDownRefresh(); 关闭
		},
		onUnload() { //监听页面卸载

		},
		onHide() { //监听页面隐藏

		},
		onLoad() { // 替代 created 监听页面加载，其参数为上个页面传递的数据，参数类型为Object（用于页面传参），参考示例

		},
		onReady() { //替代 mounted 监听页面初次渲染完成
			var myDate = new Date();
			this.tiem = myDate.toLocaleDateString();
			console.log(this.tiem)
		},

		onShow() { //监听页面显示
			//生命周期

		}
	}
</script>
<style scoped>
	.home {
		width: 100%;
		height: 100%;

	}

	img {
		width: 100%;
		height: 100%;
	}

	.img_box {
		width: 20vw;
		height: 20vw;
		margin-left: 10px;
		margin-top: 10px;
	}

	.list_text {
		width: 95%;
		heihgt: 15vw;
		border-bottom: 1px solid #ededed;
		float: left;
		margin-left: 2.5%;
	}

	.not_thing {
		width: 100%;
		height: 14vw;
		background: white;
	}

	img {
		width: 100%;
		height: 100%;

	}

	.uni-textarea {
		width: 95%;
		height: 18vw;

		margin-left: 2.5%;
		margin-top: 20px;
		float: left;
	}

	.next_tip {
		width: 100%;
		height: 13vw;
		background: #26a2ff;
		text-align: center;
		line-height: 13vw;
		color: white;
		position: fixed;
		bottom: 0;
	}

	.to_top {
		margin-top: 30upx;
	}

	.title_choose {
		padding-left: 30upx;
	}

	.age {
		width: 64%;
		height: 6vw;
		text-align: center;
		line-height: 6vw;
		font-size: 1vw;
		color: gray;
		float: left;
	}

	.choose_dog {
		width: 40vw;
		height: 40vw;
		margin-left: 5%;
		margin-top: 15upx;
		float: left;
		border: 1px solid #ededed;
		box-shadow: 4px 4px 3px #ededed;
	}

	.img_box {
		width: 4vw;
		height: 4vw;
		margin-left: 19%;
		float: left;
	}

	.border_box {
		border: 0px;
	}

	.head {
		width: 60%;
		height: 60%;
		margin-left: 20%;
		margin-top: 10upx;
	}

	.name {
		font-size: 1vw;
		text-align: center;
	}

	.gender {
		width: 100%;
		height: 10vw;
	}

	.border_org {
		box-shadow: 4px 4px 3px orange;
	}

	.time_input {
		width: 100%;
		height: 15vw;
		background: white;
		border-bottom: 1px solid #ededed;
	}
</style>
